package com.elitel.frame.main.entity.vo;

import java.io.Serializable;

public class ServerStatistics {
	private String serverName;
	private String sql;
	private Long serverTime;
	private Long sqlTime;

	public long serverStartTime;
	public long serverEndTime;
	public long sqlStartTime;
	public long sqlEndTime;

	public ServerStatistics() {
	}

	public ServerStatistics(String serverName, String sql, Long serverTime, Long sqlTime) {
		super();
		this.serverName = serverName;
		this.sql = sql;
		this.serverTime = serverTime;
		this.sqlTime = sqlTime;
	}

	public static ServerStatistics createAndStartRecord(){
		ServerStatistics serverRecorder = new ServerStatistics();
		serverRecorder.serverStartTime = currentTime();
		return serverRecorder;
	}

	public void startRecord(){
		recordServerStartTime();
		recordSqlStartTime();
	}

	public static long currentTime(){
		return System.currentTimeMillis();
	}

	// here is record start Time for server and sql
	public void recordServerStartTime(){
		serverStartTime = currentTime();
	}

	public void recordServerEndTime(){
		serverEndTime = currentTime();
	}

	// here is record end time for server and sql
	public void recordSqlStartTime(){
		sqlStartTime = currentTime();
	}

	public void recordSqlEndTime(){
		sqlEndTime = currentTime();
	}

	// here is record consuming time
	public void computeConsumeTime(){
		serverTime = serverEndTime - serverStartTime;
		sqlTime = sqlEndTime - sqlStartTime;
	}

	public String getServerName() {
		return serverName;
	}
	public void setServerName(String serverName) {
		this.serverName = serverName;
	}
	public String getSql() {
		return sql;
	}
	public void setSql(String sql) {
		this.sql = sql;
	}
	public Long getServerTime() {
		return serverTime;
	}
	public void setServerTime(Long serverTime) {
		this.serverTime = serverTime;
	}
	public Long getSqlTime() {
		return sqlTime;
	}
	public void setSqlTime(Long sqlTime) {
		this.sqlTime = sqlTime;
	}

	@Override
	public String toString() {
		return "ServerStatistics [serverName=" + serverName + "]";
	}


	 
	 
	 
}
